<?php

/**
 * @copyright 2011
 * @version $Id$
 * @access public
 * @author Oriotiori

 */

class Admin_Model_Facade_Manufacturers{
	
	/**
	 * Obtiene los manufacturers
	 * @return array $data
	 */
	public function getManufacturers()
	{
		$TBD_Resource = new Admin_Model_Manufacturers();
		try{
			$data = $TBD_Resource->getManufacturers();
			return $data;
		}catch(Exception $e)
		{
			$error=array($e->getFile(), 'Exception: '.$e->getMessage());
			$ExceptionHandler= new Default_Model_ExceptionHandler();
			$ExceptionHandler->saveErrors($error);
		}
		return false;
	}
	
	
	/**
	 * Add Manufacturer
	 * @param array $to: Array de datos a guardar.
	 * @return array $data
	 */
	public function addManufacturer($to)
	{
		$TBD_Resource = new Admin_Model_Manufacturers();
		try{
			$data = $TBD_Resource->addManufacturer($to);
			return $data;
		}catch(Exception $e)
		{
			$error=array($e->getFile(), 'Exception: '.$e->getMessage());
			$ExceptionHandler= new Default_Model_ExceptionHandler();
			$ExceptionHandler->saveErrors($error);
		}
		return false;
	}

	
	/**
	* Add Manufacturer
	* @param array $to: Array de datos a guardar.
	* @return array $data
	*/
	public function updateManufacturer($to)
	{
		$TBD_Resource = new Admin_Model_Manufacturers();
		try{
			$data = $TBD_Resource->updateManufacturer($to);
			return true;
		}catch(Exception $e)
		{
			$error=array($e->getFile(), 'Exception: '.$e->getMessage());
			$ExceptionHandler= new Default_Model_ExceptionHandler();
			$ExceptionHandler->saveErrors($error);
		}
		return false;
		}
	
	
	/**
	* Obtiene manufacturer by id
	* @param int $id
	* @return array $data
	*/
	public function readManufacturerById($id=0)
	{
		$TBD_Resource = new Admin_Model_Manufacturers();
		try{
			$data = $TBD_Resource->readManufacturerById($id);
			return $data;
		}catch(Exception $e)
		{
			$error=array($e->getFile(), 'Exception: '.$e->getMessage());
			$ExceptionHandler= new Default_Model_ExceptionHandler();
			$ExceptionHandler->saveErrors($error);
		}
		return false;
	}
	
	
	/**
	* @param array $to: Array de datos a guardar.
	* @return array $data
	*/
	public function AddImageDB($to)
	{
		$TBD_Resource = new Admin_Model_Manufacturers();
		try{
			$data = $TBD_Resource->AddImageDB($to);
			return $data;
		}catch(Exception $e)
		{
			$error=array($e->getFile(), 'Exception: '.$e->getMessage());
			$ExceptionHandler= new Default_Model_ExceptionHandler();
			$ExceptionHandler->saveErrors($error);
		}
		return false;
	}
	
	
	/**
	* @param array $resource: Array de datos
	* @return boolean $data
	*/
	public function CreateThumb($to)
	{
		$TBD_Resource = new Admin_Model_Manufacturers();
		$facadeConfigs= new Admin_Model_Facade_Configs();
		$configs=$facadeConfigs->getConfigs();
		
		try{
			$to['Width']=$configs['Manufacturer_Thumb_Width'];
			$to['Height']=$configs['Manufacturer_Thumb_Height'];
			$to['Path']='Real';
			$to['Directory']='manufacturer';
			$to['NewPath']='Thumb';
		    $to['mode']='Thumb';
		    $data = $TBD_Resource->CreateThumb($to);
		    return $data;
		}catch(Exception $e)
		{
			$error=array($e->getFile(), 'Exception: '.$e->getMessage());
			$ExceptionHandler= new Default_Model_ExceptionHandler();
			$ExceptionHandler->saveErrors($error);
		}
		return false;
	}
	
	
	/**
	* @param int $id
	* @return array $data
	*/
	public function deleteManufacturerById($id=0)
	{
		$TBD_Resource = new Admin_Model_Manufacturers();
		try{
			$data = $TBD_Resource->deleteManufacturerById($id);
			return $data;
		}catch(Exception $e)
		{
			$error=array($e->getFile(), 'Exception: '.$e->getMessage());
			$ExceptionHandler= new Default_Model_ExceptionHandler();
			$ExceptionHandler->saveErrors($error);
		}
		return false;
	}
	
		

}
